﻿using FluentValidation;
using Microsoft.AspNetCore.Identity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Quickly.Identity.Services.Manage;

public record LoadRoleDetailCommand(string Id);
public class LoadRoleDetailCommandValidator : AbstractValidator<LoadRoleDetailCommand>
{
    public LoadRoleDetailCommandValidator()
    {
        RuleFor(x => x.Id).NotNull().NotEmpty().WithMessage("Id不能为空");
    }
}

public class LoadRoleDetail
{
    static LoadRoleDetailCommandValidator validator = new LoadRoleDetailCommandValidator();

    public static Task<TRole?> ExecuteAsync<TRole>(
        LoadRoleDetailCommand command,
        IRoleStore<TRole> roleStore, 
        CancellationToken cancellationToken) 
        where TRole : class
    {
        cancellationToken.ThrowIfCancellationRequested();
        return roleStore.FindByIdAsync(command.Id, cancellationToken);
    }
}
